var evalVue = new Vue({
	el: "#app",
	data: {
		title: "",
		isExcute: false,
		isBottom: false,
		page: 1,
		queryType: 'prod',
		defaultPhotoPath:"",
		productGuid:"",
		type:3,
		tab_arr: [{
			msg: "最新",
			type: 3,
			active:true
		}, {
			msg: "好评",
			type: 2,
			active:false
		}, {
			msg: "有图",
			type: 1,
			active:false
		}],
		evals:[]
	},
	methods: {
		chooseType:function(item){
			this.type = item.type;
			this.tab_arr.forEach(function(e){
				e.active = false;
			});
			item.active = true;
			this.page = 1;
			this.evals = [];
			this.isBottom = false;
			this.getEvals();
		},
		getEvals: function() {
			var t = this;
			if (this.isBottom) return !1;
			wx.showLoading({
				title: "加载中",
				mask: !0
			}), this.$http.post(baseUrl+"eval/list", {
				productGuid: this.productGuid,
				type: this.queryType,
				group: this.type,
				currentPage: this.page,
				pageSize: 10
			}).then(function(a) {
				wx.hideLoading();
				var i = a.data;
				if (i.success)
					if (0 == i.data.length && 1 == t.page) wx.showToast({
						title: "当前没有评论",
						icon: "none",
						duration: 2e3,
						mask: !1
					});
					else if (0 == i.data.length && t.page > 1) wx.showToast({
					title: "没有更多评论了",
					icon: "none",
					duration: 2e3,
					mask: !1
				}), t.isBottom = true;
				else if (i.data.length > 0 && 1 == t.page) t.evals = i.data;
				else {
					i.data.forEach(function(e) {
						t.evals.push(e);
					});
				} else wx.showToast({
					title: i.description,
					icon: "",
					duration: 2e3,
					mask: !1
				});
			}).catch(function(t) {
				wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !0
				});
			});
		},
		handleScroll: function() {
			// 防止重复
			if (this.isExcute) {
				return;
			}
			if (this.isBottom) {
				return;
			}
			var flag = srollEvent.isReachBottom();
			if (!flag) {
				return;
			}
			this.isExcute = true;
			this.page++;
			this.getEvals();
		},
	},
	mounted: function() {
		window.addEventListener("scroll", this.handleScroll, {
			passive: false
		});
	},
	created: function() {
		var title = URLParam.get("title");
		var type = URLParam.get("type");
		var productGuid = URLParam.get("productGuid");
		this.productGuid = productGuid;
		this.queryType = type;
		this.title = title;
		this.getEvals();
	}
});
